#ifndef YCCONTROLSTASKTIMEDIALOG_H
#define YCCONTROLSTASKTIMEDIALOG_H
#include <QDialog>
#include <QPointer>

QT_BEGIN_NAMESPACE
class QLabel;
class QProgressBar;
QT_END_NAMESPACE

namespace yc {
class Task;

class TaskTimeDialog : public QDialog
{
    Q_OBJECT

public:
    TaskTimeDialog(yc::Task* task, const QString& error_msg, QWidget* parent = nullptr);
    ~TaskTimeDialog() override;

protected:
    void closeEvent(QCloseEvent* ce) override;

private:
    void updateLeftTime(qint64 msecs);
    void onProgressTimer();
    qreal percent() const;
    void onFailed(int error, const QString& message);

    const QString error_msg_;
    QProgressBar* progress_bar_;
    QTimer* timer_;
    QPointer<yc::Task> task_;
    QLabel* left_label_;
};

} // namespace yc

#endif // YCCONTROLSTASKTIMEDIALOG_H
